package com.hongmeng.web.controller.operater.operaterUser;

import java.util.List;

import com.hongmeng.operater.domain.operaterUser.SaveCustomer;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.hongmeng.common.annotation.Log;
import com.hongmeng.common.core.controller.BaseController;
import com.hongmeng.common.core.domain.AjaxResult;
import com.hongmeng.common.enums.BusinessType;
import com.hongmeng.operater.domain.operaterUser.HmCustomer;
import com.hongmeng.operater.service.operaterUser.IHmCustomerService;
import com.hongmeng.common.utils.poi.ExcelUtil;
import com.hongmeng.common.core.page.TableDataInfo;

/**
 * 企业信息Controller
 * 
 * @author hongmeng
 * @date 2021-01-18
 */
@ApiOperation("企业信息Controller")
@RestController
@RequestMapping("/operater/customer")
public class HmCustomerController extends BaseController
{
    @Autowired
    private IHmCustomerService hmCustomerService;

    /**
     * 查询企业信息列表
     */
    @ApiOperation("查询企业信息列表")
    @PreAuthorize("@ss.hasPermi('operater:customer:list')")
    @GetMapping("/list")
    public TableDataInfo list(String customerName,String customerNo)
    {
        HmCustomer hmCustomer = new HmCustomer();
        hmCustomer.setCustomerName(customerName);
        hmCustomer.setCustomerNo(customerNo);
        startPage();
        List<HmCustomer> list = hmCustomerService.selectHmCustomerList(hmCustomer);
        return getDataTable(list);
    }

    /**
     * 导出企业信息列表
     */
    @PreAuthorize("@ss.hasPermi('operater:customer:export')")
    @Log(title = "企业信息", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(HmCustomer hmCustomer)
    {
        List<HmCustomer> list = hmCustomerService.selectHmCustomerList(hmCustomer);
        ExcelUtil<HmCustomer> util = new ExcelUtil<HmCustomer>(HmCustomer.class);
        return util.exportExcel(list, "operaterUser");
    }

    /**
     * 获取企业信息详细信息
     */
    @ApiOperation("获取企业信息详细信息")
    @PreAuthorize("@ss.hasPermi('operater:customer:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Integer id)
    {
        return AjaxResult.success(hmCustomerService.selectHmCustomerById(id));
    }

    /**
     * 新增企业信息
     */
    @ApiOperation("新增企业信息")
    @PreAuthorize("@ss.hasPermi('operater:customer:add')")
    @Log(title = "企业信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SaveCustomer hmCustomer)
    {
        return hmCustomerService.insertHmCustomer(hmCustomer);
    }

    /**
     * 修改企业信息
     */
    @ApiOperation("修改企业信息")
    @PreAuthorize("@ss.hasPermi('operater:customer:edit')")
    @Log(title = "企业信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SaveCustomer hmCustomer)
    {
        return hmCustomerService.updateHmCustomer(hmCustomer);
    }

    /**
     * 删除企业信息
     */
    @ApiOperation("批量删除企业信息")
    @PreAuthorize("@ss.hasPermi('operater:customer:remove')")
    @Log(title = "企业信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Integer[] ids)
    {
        return toAjax(hmCustomerService.deleteHmCustomerByIds(ids));
    }
}
